function main() {
	if (openLogConsole) {
		resetConsole();
		openConsole();
	}

	mailClassifier();
}

function mailClassifier() {
	var account = getAccountFromIdentityName(accountName);
	var rootFolder = getAccountFolder(account);
	var inboxFolder = getSubfolderFromName(rootFolder, mainFolderName);
	var tdcStructArray = [];

	/*
	 * Browse mail in inboxFolder except those are in ignore list
	 */
	if (debugEnabled) {
		log("#################### browseMails ####################");
	}
	browseMails(tdcStructArray, inboxFolder, ignoreList);
	if (debugEnabled) {
		dumpObject(tdcStructArray);
		for (var e in tdcStructArray) {
			log(tdcStructArray[e].nbMails + " => " + e);
		}
	}

	/*
	 * List all subfolders in root folder and construct tdcStruct for each
	 */
	if (debugEnabled) {
		log("#################### browseFolders ####################");
	}
	browseFolders(tdcStructArray, rootFolder)
	if (debugEnabled) {
		dumpObject(tdcStructArray);
	}

	/*
	 * Create a folder for each domain (if not already exists)
	 */
	if (debugEnabled) {
		log("#################### createFolders ####################");
	}
	createFolders(tdcStructArray, rootFolder, neededMessageCount);
	
	/*
	 * Move mails in correct folders
	 */
	if (debugEnabled) {
		log("#################### moveMails ####################");
	}
	moveMails(tdcStructArray, inboxFolder);
	
	
	if (debugEnabled) {
		log("#################### END ####################");
	}
}
